package main

import "fmt"

type myStruct struct {
	name string
	age  int
}

type part struct {
	description string
	count       int
}

type Subscriber struct {
	name   string
	rate   float64
	active bool
}

func main() {
	var myS myStruct
	myS.name = "zhang3"
	myS.age = 18
	fmt.Printf("%#v\n", myS)
	myS1 := myStruct{"li4", 22}
	fmt.Printf("%#v\n", myS1)
	bolts := part{description: "Hex bolts", count: 24}
	showInfo(bolts)
	p := minimumOrder("houlin")
	showInfo(p)
	fmt.Println("--------------")
	subscriber1 := defaultSubscriber("wang5")
	//subscriber1.rate = 4.99
	applyDiscount(&subscriber1)
	printInfo(subscriber1)
	subscriber2 := defaultSubscriber("chen6")
	printInfo(subscriber2)
}

func showInfo(p part) {
	fmt.Println("Description", p.description)
	fmt.Println("Count", p.count)
}

func minimumOrder(description string) part {
	p := part{description, 24}
	return p
}

func printInfo(s Subscriber) {
	fmt.Println("Name:", s.name)
	fmt.Println("Rate:", s.rate)
	fmt.Println("Active:", s.active)
}

func defaultSubscriber(name string) Subscriber {
	var s Subscriber
	s.name = name
	s.rate = 5.99
	s.active = true
	return s
}

func applyDiscount(s *Subscriber) {
	s.rate = 4.99
}
